package org.interview.reflection.hashcode;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PojoHashCodeEquals0Test
{

	private static final long count = 10000;

	public static void main(String[] args)
	{
		
		List<PojoHashCodeEquals0> list = PojoGenerator.generatePojoHashCodeEquals0(count);
		
		Map<PojoHashCodeEquals0, String> map = new HashMap<PojoHashCodeEquals0, String>();
		
		for (PojoHashCodeEquals0 pojoHashCodeEquals0 : list) {
			map.put(pojoHashCodeEquals0, pojoHashCodeEquals0.getName());
		}
		
		System.out.println("collection size : " + map.size());
		
		long start = System.currentTimeMillis();
		for (PojoHashCodeEquals0 pojoHashCodeEquals0 : list) {
			
			PojoHashCodeEquals0 pojoHashCodeEquals0forSearch = new PojoHashCodeEquals0();
			pojoHashCodeEquals0forSearch.setId(pojoHashCodeEquals0.getId());
			String value = map.get(pojoHashCodeEquals0forSearch);
			
			if (!value.equals(pojoHashCodeEquals0.getName()))
			{
				System.out.println("error: pojo found wrong");
			}
		}
		long finish = System.currentTimeMillis();
		long result = finish - start;
		System.out.println("Result = " + result + " ms");

	}

		
	}
	

